var app = getApp();

Page({
  data: {
    header: [],
    managers: [],
    members: [],
    noFlag: !1,
    // searchFlag: !1,
    searchFlag:1,
    teamitem: ['团队成员', '邀请记录'],
    teamindex: 0,
    type:0,
    list:[],
    page:0,
    pagesize:10,
    myadd: [{}, {}],
    myyq:[{},{},{},{}],
    id:""
  },
  teamtab: function (e) {
    const index = e.currentTarget.dataset.dex;
    this.setData({
      teamindex: index,
      type:index,
      page:0,
      list:[]
    })
    this.getList(index);
  },
  yaoqing:function(e){
    var that = this;
    var y_zid = e.currentTarget.dataset.y_zid;
    var y_openid = e.currentTarget.dataset.y_openid;
    var openid = wx.getStorageSync('openid');
    var zid = wx.getStorageSync('zid');
    app.util.request({
      'url':"entry/wxapp/team.invitation",
      data:{
        openid:openid,
        zid:zid,
        y_zid:y_zid,
        y_openid,y_openid,
        tid:that.data.id
      },
      success:function(res){
        if(res.data.code == '1')
        {
          wx.showToast({
            title: res.data.message,
          })
          
        }else{
          wx.showToast({
            title: res.data.message,
          })
        }
        that.setData({
          page:0,
          list:[]
        })
        setTimeout(() => {
          that.getList(1);
        }, 500);
      }
    })
  },
  onLoad: function (e) {
    var bgc = wx.getStorageSync('color')
    wx.setNavigationBarColor({
      frontColor: "#ffffff",
      backgroundColor: bgc,
    })
    var that = this;
    var id = e.id;
    that.setData({
      id:id
    })
    that.getList(0);
  },
  fenpei:function(e){
    wx.navigateTo({
      url: '/hyb_yl/doctorHome/pages/patientlists/patientlists?zid='+e.currentTarget.dataset.zid+'&t_id='+this.data.id+'&typs=fenpei',
    })
  },
  getList:function(type){
    var that = this;
    app.util.request({
      'url':"entry/wxapp/team.team_people",
      data:{
        id:that.data.id,
        page:that.data.page,
        pagesize:that.data.pagesize,
        type:type
      },
      success:function(res){
        var page = that.data.page + 1;
        that.setData({
          list:that.data.list.concat(res.data),
          page:page
        })
      }
    })
  },
  onReady: function() {},
  onShow: function() {},
  onHide: function() {},
  onUnload: function() {},
  onPullDownRefresh: function() {},
  onReachBottom: function() {
    var that = this;
    var type = that.dat.type;
    that.getList(type);
  },
  onShareAppMessage: function() {}
});